home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / net / pronet21.lha / source / utilities / pronet-talk.s
Text File  |  1995-07-07  |  8KB  |  384 lines

  1. ;: Talk.s
  2. ;:
  3. ;: 03-06-1995    UNIT support. v34.1
  4. ;: 07-07-1995    Well.. it didn't work :)) v34.2
  5.  
  6. CSI        equ    27+128
  7. USEPRONET    equ    1    ;zum Testen..
  8.  
  9.         include    "A:OSmacros.i"
  10.         include    "exec/exec.i"
  11.         include    "intuition/intuition.i"
  12.         include    "A:ProNET/include/devices/pronet.i"
  13.         include    "exec_lib.i"
  14.         include    "intuition_lib.i"
  15.  
  16. j        bsr    dec2long    * UNIT as Argument
  17.         move.l    d1,unit
  18.  
  19.         lea    wintitle2mod(pc),a0
  20.         move.l    unit(pc),d0
  21.         bsr    long2dec
  22.         clr.b    (a0)+
  23.  
  24.         move.l    4.w,a6
  25.         lea    intname(pc),a1
  26.         LIBCALL    OldOpenLibrary
  27.         move.l    d0,intbase
  28.  
  29.         bsr    initconsole
  30.         tst.w    d0
  31.         bne    noconsole
  32.  
  33.         IFNE    USEPRONET
  34.         bsr    startpronet
  35.         tst.w    d0
  36.         bne    nopronet
  37.         ENDC    
  38.         move.l    intbase(pc),a6
  39.         move.l    window(pc),a0
  40.         lea    wintitle2(pc),a1
  41.         move.l    a1,a2
  42.         LIBCALL    SetWindowTitles
  43.  
  44.         bsr    Wait4Message
  45.  
  46.         IFNE    USEPRONET
  47.         bsr    stoppronet
  48.         ENDC
  49.  
  50. nopronet    bsr    closeconsole
  51.  
  52. noconsole    move.l    intbase(pc),a1
  53.         move.l    4.w,a6
  54.         LIBCALL    CloseLibrary
  55.         moveq    #0,d0
  56.         rts
  57.  
  58.         dc.b    "$VER: pronet-talk 34.2 (07-07-95)",13,10,0
  59.         even
  60.  
  61. initconsole    move.l    intbase(pc),a6        ;Window öffnen
  62.         cmp.w    #36,LIB_VERSION(a6)
  63.         bcs.s    .nokick2
  64.         lea    wbname(pc),a0
  65.         LIBCALL    LockPubScreen
  66.         move.l    d0,wbscreen
  67.         beq    icnoscr
  68.         move.l    d0,a0
  69.         moveq    #0,d1
  70.         move.b    sc_WBorTop(a0),d1
  71.         add.b    sc_WBorBottom(a0),d1
  72.         add.w    sc_RastPort+rp_TxHeight(a0),d1
  73.         add.w    #2+100,d1
  74.         move.w    d1,newwindow+6
  75. .nokick2    lea    newwindow(pc),a0
  76.         LIBCALL    OpenWindow
  77.         move.l    d0,window
  78.         beq    icnowin
  79.  
  80.         moveq    #48,d0            ;Console-Device öffnen
  81.         bsr    GetIORequest
  82.         move.l    d0,conreadio
  83.         beq    nodevblock1
  84.         moveq    #48,d0
  85.         bsr    GetIORequest
  86.         move.l    d0,conwriteio
  87.         beq    nodevblock2
  88.         move.l    conreadio(pc),a1
  89.         move.l    window(pc),IO_DATA(a1)
  90.         lea    consolename(pc),a0
  91.         moveq    #0,d0
  92.         moveq    #0,d1
  93.         move.l    4.w,a6
  94.         LIBCALL    OpenDevice
  95.         tst.l    d0
  96.         bne    nocondev
  97.         move.l    conreadio(pc),a0
  98.         move.l    conwriteio(pc),a1
  99.         move.l    20(a0),20(a1)
  100.         move.l    24(a0),24(a1)
  101.  
  102.         move.l    window(pc),a0
  103.         move.l    wd_UserPort(a0),a0
  104.         move.b    MP_SIGBIT(a0),Signal.window
  105.         move.l    conreadio(pc),a0
  106.         move.l    MN_REPLYPORT(a0),a0
  107.         move.b    MP_SIGBIT(a0),Signal.console
  108.  
  109.         bsr    sendconreadcmd
  110.         moveq    #0,d0
  111.         rts
  112.  
  113. sendconreadcmd    move.l    4.w,a6
  114.         moveq    #0,d0
  115.         moveq    #0,d1
  116.         move.l    conreadio(pc),a0
  117.         move.l    MN_REPLYPORT(a0),a0
  118.         move.b    MP_SIGBIT(a0),d2
  119.         bset    d2,d1
  120.         LIBCALL    SetSignal
  121.         move.l    conreadio(pc),a1
  122.         clr.b    IO_FLAGS(a1)
  123.         move.l    #256,IO_LENGTH(a1)
  124.         move.l    #conbuf,IO_DATA(a1)
  125.         move.w    #CMD_READ,IO_COMMAND(a1)
  126.         LIBCALL    SendIO
  127.         rts
  128.  
  129. closeconsole    move.l    4.w,a6
  130.         move.l    conreadio(pc),a1
  131.         LIBCALL    CloseDevice
  132. nocondev    move.l    conwriteio(pc),a0
  133.         bsr    FreeIORequest
  134. nodevblock2    move.l    conreadio(pc),a0
  135.         bsr    FreeIORequest
  136. nodevblock1    move.l    intbase(pc),a6
  137.         move.l    window(pc),a0
  138.         LIBCALL    CloseWindow
  139. icnowin        cmp.w    #36,LIB_VERSION(a6)
  140.         bcs.s    icnoscr
  141.         sub.l    a0,a0
  142.         move.l    wbscreen(pc),a1
  143.         LIBCALL    UnlockPubScreen
  144. icnoscr        moveq    #-1,d0
  145.         rts
  146.  
  147. startpronet    moveq    #pnr_Size,d0
  148.         bsr    GetIORequest
  149.         move.l    d0,pronetio
  150.         beq    spnoioreq
  151.         bsr    CreatePort
  152.         move.l    d0,msgport
  153.         beq    spnomsgport
  154.         lea    pronetname,a0
  155.         move.l    unit(pc),d0
  156.         moveq    #0,d1
  157.         move.l    pronetio(pc),a1
  158.         move.w    #PNP_NAME,pnr_NetSourcePort(a1)
  159.         move.l    msgport(pc),pnr_MsgPort(a1)
  160.         move.l    #talkstr,pnr_Data1(a1)
  161.         move.l    4.w,a6
  162.         LIBCALL    OpenDevice
  163.         tst.l    d0
  164.         bne    spnodev
  165.  
  166.         move.l    pronetio(pc),a1
  167.         move.w    pnr_NetSourcePort(a1),pnr_NetDestPort(a1)
  168.         clr.l    pnr_Data2(a1)
  169.         clr.l    pnr_Length2(a1)
  170.  
  171.         move.l    msgport(pc),a0
  172.         move.b    MP_SIGBIT(a0),Signal.pronet
  173.         moveq    #0,d0
  174.         rts
  175.  
  176. stoppronet    move.l    4.w,a6
  177.         move.l    pronetio(pc),a1
  178.         LIBCALL    CloseDevice
  179. spnodev        move.l    msgport(pc),a0
  180.         bsr    DeletePort
  181. spnomsgport    move.l    pronetio(pc),a0
  182.         bsr    FreeIORequest
  183. spnoioreq    moveq    #-1,d0
  184.         rts
  185.  
  186. dec2long    ; konvertiert Dezimalstring ab (a0) zu Longword in D1 !!
  187.         moveq    #0,d1
  188. .loop        moveq    #0,d0
  189.         move.b    (a0)+,d0
  190.         sub.b    #"0",d0
  191.         cmp.b    #9,d0
  192.         bhi.s    .oki
  193.         move.l    d1,d2
  194.         lsl.l    #3,d1
  195.         add.l    d2,d1
  196.         add.l    d2,d1
  197.         add.l    d0,d1
  198.         bra.s    .loop
  199. .oki        rts
  200.  
  201. long2dec    ;Converts Long in d0 to Dec-String in (a0)+
  202.         tst.l    d0
  203.         bne.s    .0
  204.         move.b    #"0",(a0)+
  205.         rts
  206. .0        lea    long2asciitab(pc),a1
  207.         moveq    #9,d1
  208.         moveq    #0,d6
  209. .1        move.l    (a1)+,d2
  210.         move.l    d0,d3
  211.         moveq    #-1,d4
  212. .2        move.l    d3,d5
  213.         sub.l    d2,d3
  214.         cmp.l    d5,d3
  215.         dbhi    d4,.2
  216.         add.l    d2,d3
  217.         move.l    d3,d0
  218.         not.w    d4
  219.         bne.s    .3
  220.         tst.w    d6
  221.         beq.s    .4
  222. .3        st    d6
  223.         add.b    #"0",d4
  224.         move.b    d4,(a0)+
  225. .4        dbra    d1,.1
  226.         rts
  227. long2asciitab    dc.l    1000000000,100000000,10000000,1000000,100000
  228.         dc.l    10000,1000,100,10,1
  229.  
  230. w4mquitflag    dc.w    0
  231. Wait4Message    tst.w    w4mquitflag
  232.         bne    .quit
  233.         clr.w    w4mquitflag
  234.  
  235.         lea    Signals(pc),a3    * auf die Messages
  236.         moveq    #0,d0        * an allen möglichen
  237.         moveq    #numports-1,d1    * Ports warten
  238. .loop1        move.b    (a3),d2
  239.         bmi.s    .0
  240.         bset    d2,d0
  241. .0        addq.w    #6,a3
  242.         dbra    d1,.loop1
  243.         move.l    4.w,a6
  244.         LIBCALL    Wait
  245.                     * entsprechende Routinen
  246.         moveq    #31,d7        * aufrufen
  247. .00        rol.l    d0
  248.         bcc.s    .notthisbit
  249.         lea    Signals(pc),a3
  250.         moveq    #numports-1,d4
  251. .01        cmp.b    (a3),d7
  252.         bne.s    .notthisport
  253.         movem.l    d0/d4/d7/a3,-(sp)
  254.         move.l    2(a3),a3
  255.         jsr    (a3)
  256.         movem.l    (sp)+,d0/d4/d7/a3
  257. .notthisport    addq.w    #6,a3
  258.         dbra    d4,.01
  259. .notthisbit    dbra    d7,.00    
  260.  
  261.         bra    Wait4Message
  262. .quit        rts
  263. Signals:
  264. Signal.window    dc.b    -1,0            ;Signalbit
  265.         dc.l    EvalWindowMessage    ;Entsprechende Routine
  266. Signal.pronet    dc.b    -1,0
  267.         dc.l    ReadFromProNET
  268. Signal.console    dc.b    -1,0
  269.         dc.l    ReadFromConsole
  270. numports    equ    3
  271.  
  272. EvalWindowMessage    ; IDCMP-Flags des Window wurden aufgerufen
  273.         move.l    4.w,a6
  274.         move.l    window(pc),a0
  275.         move.l    wd_UserPort(a0),a0
  276.         LIBCALL    GetMsg
  277.         move.l    d0,a1
  278.         tst.l    d0
  279.         beq.s    .ende
  280.         move.l    $14(a1),d4    ;Class
  281.         move.w    $18(a1),d5    ;Code
  282.         move.w    $1a(a1),d6    ;Qualifier
  283.         move.l    $1c(a1),a4    ;IAddress
  284.         cmp.l    #IDCMP_CLOSEWINDOW,d4
  285.         bne.s    .0
  286.         st    w4mquitflag
  287. .0        LIBCALL    ReplyMsg
  288.         bra.s    EvalWindowMessage
  289. .ende        rts
  290.  
  291. ReadFromProNET        ; Message vom anderen Rechner
  292.         move.l    4.w,a6
  293.         move.l    msgport(pc),a0
  294.         LIBCALL    GetMsg
  295.         tst.l    d0
  296.         beq.s    .ende
  297.         move.l    d0,a3
  298.         move.l    conwriteio(pc),a1
  299.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  300.         move.l    a3,d0
  301.         add.l    #MN_SIZE+6,d0
  302.         move.l    d0,IO_DATA(a1)
  303.         move.l    MN_SIZE+2(a3),d0
  304.         move.l    d0,IO_LENGTH(a1)
  305.         clr.b    IO_FLAGS(a1)
  306.         LIBCALL    DoIO        ;und auf der Console ausgeben
  307.         move.l    a3,a1
  308.         LIBCALL    ReplyMsg
  309.         bra.s    ReadFromProNET
  310. .ende        rts
  311.  
  312.  
  313. ReadFromConsole        ; Es wurde auf der Console etwas getippt
  314.         move.l    conreadio(pc),a0
  315.         move.l    IO_ACTUAL(a0),d6    ;Anzahl der Bytes
  316.  
  317.         bsr    processconbuf
  318.  
  319.         move.l    conwriteio(pc),a1
  320.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  321.         move.l    #conbuf,IO_DATA(a1)
  322.         move.l    d6,IO_LENGTH(a1)
  323.         clr.b    IO_FLAGS(a1)
  324.         LIBCALL    DoIO            ;auf der Console ausgeben
  325.  
  326.         IFNE    USEPRONET
  327.         move.l    pronetio(pc),a1
  328.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  329.         lea    conbuf-4,a0
  330.         move.l    a0,pnr_Data1(a1)
  331.         move.l    d6,(a0)
  332.         addq.l    #1,d6
  333.         bclr    #0,d6    ;aufrunden
  334.         addq.l    #4,d6    ;Längenwort !
  335.         move.l    d6,pnr_Length1(a1)
  336.         LIBCALL DoIO            ;und auf dem anderen Amiga
  337.         ENDC
  338.  
  339.         bsr    sendconreadcmd        ;neue Sachen lesen
  340.         rts
  341.  
  342. processconbuf    ; Ein paar Tasten umdefinieren (Cursor, Del etc.)
  343.         ; alte Länge der Daten in D6.l
  344.         ; muß neue Länge in D6.l zurückgeben
  345.         rts
  346.  
  347. ; - Data ------------------------------------------------------------------
  348.  
  349. pronetname    dc.b    "pronet.device",0
  350. consolename    dc.b    "console.device",0
  351. intname        dc.b    "intuition.library",0
  352. wbname        dc.b    "Workbench",0
  353.         even
  354.  
  355. newwindow    dc.w    50,50
  356.         dc.w    400,114
  357.         dc.b    -1,-1
  358.         dc.l    IDCMP_CLOSEWINDOW,$1100e,0,0,wintitle,0,0
  359.         dc.w    -1,-1,-1,-1,$1
  360.  
  361. wintitle    dc.b    "ProNET-Talk! - Starting ProNET..",0
  362. wintitle2    dc.b    "ProNET-Talk! Unit "
  363. wintitle2mod    dc.b    "XXXXXXXX",0
  364.  
  365. talkstr        dc.b    "pronet-talk:",0
  366.         even
  367.  
  368. unit        dc.l    0
  369.  
  370. pronetio    dc.l    0
  371. msgport        dc.l    0
  372. intbase        dc.l    0
  373. window        dc.l    0
  374. wbscreen    dc.l    0
  375. conreadio    dc.l    0
  376. conwriteio    dc.l    0
  377.  
  378.         include    "A:ProNET/source/devio.s"
  379.  
  380.         section    b,bss
  381.  
  382.         ds.b    4
  383. conbuf        ds.b    256
  384.